package com.brainyx.sample;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;

import com.actionbarsherlock.internal.widget.IcsAdapterView;
import com.actionbarsherlock.internal.widget.IcsAdapterView.OnItemSelectedListener;
import com.actionbarsherlock.internal.widget.IcsSpinner;
import com.brainyxlib.BrUtilManager;
import com.brainyxsample.R;

public class IcsStyleSpinner extends Activity{

	IcsSpinner spinnerMainTran;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		BrUtilManager.getInstance().onActivityNoTitle(this);
		setContentView(R.layout.icsstyle);
		
		init();
		
	}
	
	private void init(){
		spinnerMainTran = (IcsSpinner)findViewById(R.id.spinnerMainTran);
		ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(
				this, R.array.qs_11, R.layout.spinner_item);
		spinnerAdapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
		spinnerMainTran.setAdapter(spinnerAdapter);
		
		spinnerMainTran.setOnItemSelectedListener(new OnItemSelectedListener() {
			@Override
			public void onItemSelected(IcsAdapterView<?> parent, View view,
					int position, long id) {
				// TODO Auto-generated method stub
				try {	
					BrUtilManager.getInstance().showToast(IcsStyleSpinner.this, "선택한 아이템은 = " + position + " 번째 입니다.");
				} catch (Exception e) {
					e.printStackTrace();
				}
			}

			@Override
			public void onNothingSelected(IcsAdapterView<?> parent) {
				
			}
		});
	}
}
